package Client.GUI;

import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.BoxLayout;
import javax.swing.border.EmptyBorder;

import Server.DataBase.User;

import Client.logic.ClientIF;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SideBar extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ClientIF clientFrame;
	private User user;
	
	
	public void setUser(User user) {
		this.user = user;
	}

	public SideBar(ClientIF clientFrame, User user) {
		this.clientFrame = clientFrame;
		this.user = user;
		setBorder(new EmptyBorder(5, 10, 5, 30));
		setBackground(Color.cyan);
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		initLogin();
	}
	
	public void initLogin(){
		JLinkButton login = new JLinkButton("Login");
		login.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new LogInPanel(clientFrame));
			}
		});
		this.add(login);
		JLinkButton loginSettings = new JLinkButton("Settings");
		loginSettings.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new LoginSettingsPanel(clientFrame));
			}
		});
		this.add(loginSettings);
	}
	
	public void clearSideBar(){
		this.removeAll();
		clientFrame.setVisible();
	}
	
	public void initSecertary(){	
			removeAll();
			JLinkButton home = new JLinkButton("Home");
			home.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new HomePanelSecratery(clientFrame));
				}
			});
			this.add(home);
			JLinkButton addClass = new JLinkButton("Add Class");
			addClass.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new AddClassPanel(clientFrame));
				}
			});
			JLinkButton assignStudentToClass = new JLinkButton("Assign Student to Class");
			assignStudentToClass.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new AssignStudentToClassPanel(clientFrame));
				}
			});
			JLinkButton changeTeacher = new JLinkButton("Change Teacher");
			changeTeacher.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new ChangeTeacherPanel(clientFrame));
				}
			});
			JLinkButton openSemster = new JLinkButton("Open Semster");
			openSemster.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new OpenSemesterPanel(clientFrame));
				}
			});
			JLinkButton removeStudentFromCourse = new JLinkButton("Remove Student From Course");
			removeStudentFromCourse.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new RemoveStudentFromCoursePanel(clientFrame));
				}
			});
			JLinkButton assignStudentToCourse = new JLinkButton("Assign Student to Course");
			assignStudentToCourse.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					clientFrame.swap(new AssignStudentToCoursePanel(clientFrame));
				}
			});
		this.add(addClass);
		this.add(assignStudentToClass);
		this.add(changeTeacher);
		this.add(openSemster);
		this.add(removeStudentFromCourse);
		this.add(assignStudentToCourse);
		clientFrame.setVisible();
	}
	
	public void initTeacher(){
		removeAll();
		JLinkButton home = new JLinkButton("Home");
		home.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new HomePanelTeacher(clientFrame));
			}
		});
		this.add(home);
		JLinkButton addTask = new JLinkButton("Add Task");
		addTask.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new AddTaskPanel(clientFrame));
			}
		});
		this.add(addTask);
		JLinkButton getSubmittedTask = new JLinkButton("Get Submitted Task");
		getSubmittedTask.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new GetSubmittedTaskPanel(clientFrame));
			}
		});
		this.add(getSubmittedTask);
		JLinkButton gradeTask = new JLinkButton("Grade Task");
		gradeTask.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new GradeTaskPanel(clientFrame));
			}
		});
		this.add(gradeTask);
		clientFrame.setVisible();
		
		JLinkButton  AssesmentForm = new JLinkButton("Assesment Form");
		 AssesmentForm.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new AssesmentForm(clientFrame));
			}
		});
			this.add(AssesmentForm);
		
	}
	
	public void initStudent(){
		removeAll();
		JLinkButton home = new JLinkButton("Home");
		home.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new HomePanelStudent(clientFrame));
			}
		});
		this.add(home);
		JLinkButton getTask = new JLinkButton("Get Task");
		getTask.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new GetTaskPanel(clientFrame));
			}
		});
		this.add(getTask);
		JLinkButton submitTask = new JLinkButton("Submit Task");
		submitTask.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new SubmitTaskPanel(clientFrame));
			}
		});
		this.add(submitTask);
		JLinkButton personalFile = new JLinkButton("Personal File");
		personalFile.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new PersonalFilePanel(clientFrame, user));
			}
		});
		this.add(personalFile);
	}
	
	public void initParent(){
		removeAll();
		JLinkButton home = new JLinkButton("Home");
		home.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new HomePanelParent(clientFrame));
			}
		});
		this.add(home);
		JLinkButton personalFile = new JLinkButton("Personal File");
		personalFile.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new PersonalFileParent(clientFrame));
			}
		});
		this.add(personalFile);
	}
	
	public void initManager(){
		removeAll();
		JLinkButton home = new JLinkButton("Home");
		home.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new HomePanelManager(clientFrame));
			}
		});
		this.add(home);
		
		JLinkButton viewInfo = new JLinkButton("View Info");
		viewInfo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new ManagerViewInfoPanel(clientFrame));
			}
		});
		this.add(viewInfo);
		
		JLinkButton requests = new JLinkButton("Requests");
		requests.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new RequestsPanel(clientFrame));
			}
		});
		this.add(requests);
		
		JLinkButton reports = new JLinkButton("Reports");
		reports.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new ReportsPanel(clientFrame));
			}
		});
		this.add(reports);
		
		JLinkButton block = new JLinkButton("Block Parent");
		block.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clientFrame.swap(new BlockParentsPanel(clientFrame));
			}
		});
		this.add(block);
		
	}
	

}
